class Task58:
    def run(self, string):
        array = list(string)
        self.flip_array(array, 0, len(array))

        start_index = 0
        end_index = 0

        while True:
            while start_index < len(array) and array[start_index] == ' ':
                start_index += 1
            if start_index == len(array):
                break
            end_index = start_index
            while end_index < len(array) and array[end_index] != ' ':
                end_index += 1
            self.flip_array(array, start_index, end_index)
            start_index = end_index
        return ''.join(array)

    def flip_array(self, array, start, end):
        start_index = start
        end_index = end - 1
        while start_index < end_index:
            array[start_index], array[end_index] = array[end_index], array[start_index]
            start_index += 1
            end_index -= 1
